/*
 * @lc app=leetcode.cn id=367 lang=java
 *
 * [367] 有效的完全平方数
 */

// @lc code=start
class Solution {
    public boolean isPerfectSquare(int num) {
        int left=0;
        int right=num;
        while(left<=right){
            int middle=left+(right-left)/2;
            long powValue=(long)middle*middle;
            if(num==powValue){
                return true;
            }else if(num<powValue){
                right=middle-1;
            }else{
                left=middle+1;
            }
        }
        return false;
    }
}
// @lc code=end

